public class HashBucket_KV<K, V> {
    static class Node<K, V> {
        public K key;
        public V val;
        public Node<K, V> next;

        public Node(K key, V val) {
            this.key = key;
            this.val = val;
        }
    }

    public Node<K, V>[] hashTable;
    public int usedSize;

    public HashBucket_KV() {
        hashTable = (Node<K, V>[])new Node[10];
    }

    public void put(K key, V val) {
        int hash = key.hashCode();
        int index = hash % hashTable.length;
        Node<K, V> cur = hashTable[index];
        while(cur != null) {
            if(cur.key.equals(key)) {
                cur.val = val;
                return;
            }
            cur = cur.next;
        }
        Node<K, V> node = new Node<>(key, val);
        node.next = hashTable[index];
        hashTable[index] = node;
        usedSize++;
    }

    public V get(V key) {
        int hash = key.hashCode();
        int index = hash % hashTable.length;
        Node<K, V> cur = hashTable[index];
        while(cur != null) {
            if(cur.key.equals(key)) {
                return cur.val;
            }
            cur = cur.next;
        }
        return null;
    }
}
